import {get,post} from '@/utils/request.js'
import {BaseURL} from '@/config/index.js'
/**
 * 获取积分商城配置
 */
export const getSettingsApi = (data) => {
	return get('/businessPointsMall/getSettings', data)
}

/**
 * 优惠券/核销商品列表[商家自己查看]
 */
export const myProductListApi = (data) => {
	return get('/businessPointsMall/myProductList', data)
}

/**
 * 积分商品详情
 */
export const productDetailApi = (data) => {
	return get('/businessPointsMall/productDetail', data)
}

/**
 * 用户积分列表
 */
export const pageUserPointsAccountApi = (data) => {
	return get('/businessPointsMall/pageUserPointsAccount', data)
}

/**
 * 用户积分明细
 */
export const pageUserPointsDetailApi = (data) => {
	return get('/businessPointsMall/pageUserPointsDetail', data)
}

/**
 * 用户积分详情
 */
export const userPointsAccountApi = (data) => {
	return get('/businessPointsMall/userPointsAccount', data)
}

/**
 * 积分订单列表
 */
export const pagePointsOrderApi = (data) => {
	return get('/businessPointsMall/pagePointsOrder', data)
}

/**
 * 卖出订单详情(商家查看)
 */
export const sellOrderDetailApi = (data) => {
	return get('/order/sellOrderDetail', data)
}

/**
 * 商家积分商城主页
 */
export const getHomePageApi = (data) => {
	return get('/businessPointsMall/getHomePage', data)
}

/**
 * 优惠券/核销商品列表[别人查看]
 */
export const getProductListApi = (data) => {
	return get('/businessPointsMall/getProductList', data)
}

/**
 * 我的奖品[商品]
 */
export const pageMyPrizeOrderApi = (data) => {
	return get('/businessPointsMall/pageMyPrizeOrder', data)
}

/**
 * 我的奖品[卡券]
 */
export const pageMyPrizeRedPacketApi = (data) => {
	return get('/businessPointsMall/pageMyPrizeRedPacket', data)
}

/**
 * 导出积分订单
 */
export const exportPointsOrder = (data) => {
	let params = ''
	for (const key in data) {
		if (data.hasOwnProperty(key)) {
			params += `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}&`
		}
	}
	return `${BaseURL}/order/exportPointsOrder?${params}`
}
/***
*设置积分商城配置
**/ 
export const saveSettingsApi = (data) => {
	return post('/businessPointsMall/saveSettings', data)
}

/***
*添加编辑核销商品
**/ 
export const saveGoodsApi = (data) => {
	return post('/businessPointsMall/saveGoods', data)
}

/***
*添加编辑优惠券
**/ 
export const saveCouponApi = (data) => {
	return post('/businessPointsMall/saveCoupon', data)
}

/***
*删除优惠券、核销商品
**/ 
export const removeProductApi = (data) => {
	return post('/businessPointsMall/removeProduct', data)
}

/***
*开启积分商城
**/ 
export const openApi = (data) => {
	return post('/businessPointsMall/open', data)
}

/***
*关闭积分商城
**/ 
export const closeApi = (data) => {
	return post('/businessPointsMall/close', data)
}

/***
*策划人调整积分
**/ 
export const businessChangePointsApi = (data) => {
	return post('/businessPointsMall/businessChangePoints', data)
}

/***
*积分兑换
**/ 
export const exchangeApi = (data) => {
	return post('/businessPointsMall/exchange', data)
}
